{extend name="public:base" /}
{block name="breadcrumbHeader"}
<h2>审核</h2>
{/block}
{block name="action"}
{if condition="$uu == 1"}
<div class="col-12 table-responsive">
    <a type="button" class="btn btn-w-m btn-primary ajax-modal-dialog"
       data-title="您确认要审核通过本申请单吗?请慎重选择！"
       data-method="post"
       href="{:url('waitReviewAudit',['id'=>$row.id],'json')}?status=accept"
       data-title="确认通过"
    >通过</a>
    <button type="button" class="btn btn-w-m btn-danger"
            data-toggle="modal"
            data-target="#reject-form"
            data-title="">审批拒绝
    </button>
</div>
{/if}
{/block}
{block name="content"}
<div class="wrapper wrapper-content animated fadeInRight" xmlns="http://www.w3.org/1999/html">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox-footer">
                基本信息
            </div>
            <div class="ibox-content">

                <div class="row">
                    <div class="col-md-5">
                        <div class="product-images">
                            <div>
                                <div class="image-imitation" id="tencent_map_container" lat="{$row.lat}" lng="{$row.lng}" style="overflow: hidden;height: 419px;width: 100%;padding: 0;">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-7">
                        <h2 class="font-bold m-b-xs">
                            {$row.name}
                        </h2>
                        <!--<small>{$row.name}</small>-->
                        <hr>
                        <dl class="small m-t-md">
                            <dd>
                                <div class="row">
                                    <div class="col-6"><strong>申请项目:</strong> {$seal.name}</div>
                                    <div class="col-6"><strong>审批类型:</strong> {$approval.type_name}</div>
                                    <div class="col-6"><strong>文件名称:</strong> {$row.name}</div>
                                    <div class="col-6"><strong>文件编号:</strong> {$row.file_number}</div>
                                    <div class="col-6"><strong>申请内容:</strong> {$row.content}</div>
                                    <div class="col-6"><strong>实际次数:</strong> {$row.use_count}</div>
                                    <div class="col-12"><strong>备注信息:</strong> {$row.remark}</div>
                                    <div class="col-6"><strong>申请人:</strong> {$user.username}</div>
                                    <div class="col-6"><strong>抄送人:</strong> {:getCarbonUsername($row.id)}</div>
                                    <div class="col-6"><strong>申请时间:</strong> {$row.create_time}</div>
                                    <div class="col-6"><strong>用章时间:</strong> {:timeFormat($row.chapter_time)}</div>
                                    <div class="col-6"><strong>新增方式:</strong> 钉钉小程序</div>
                                    <div class="col-6"><strong>状态:</strong> {$row.status_txt}</div>
									{if condition="$reason neq ''"}<div class="col-6"><strong>拒绝理由:</strong>{$reason}</div>{/if} 
									{if condition="$wd neq ''"}
									<div class="col-6"><strong>文档:</strong>
                                        
                                            {volist name="wd" id="vo"}
                                            <a href="{$vo.src}">
                                                {$vo.name}
                                            </a>
                                            {/volist}
                                       
                                    </div>
									{/if} 
                                    <div class="col-6"><strong>申请图片:</strong>
                                        <div class="lightBoxGallery">
                                            {volist name="attachments" id="vo"}
                                            <a href="{$vo.path}" title="Image from Unsplash" data-gallery="">
                                                <img src="{$vo.path}" class="upload-file">
                                            </a>
                                            {/volist}
                                        </div>
                                    </div>
									{if condition="$attachments2"}
									<div class="col-6"><strong>完成图片:</strong>
                                        <div class="lightBoxGallery">
                                            {volist name="attachments2" id="vo"}
                                            <a href="{$vo.path}" title="Image from Unsplash" data-gallery="">
                                                <img src="{$vo.path}" class="upload-file">
                                            </a>
                                            {/volist}
                                        </div>
                                    </div>
									{/if}
                                </div>
                            </dd>
                        </dl>
                    </div>
                </div>
            </div>
            <div class="ibox-footer">
                审核流程
            </div>
        </div>
    </div>
    <div class="row animated fadeInRight">
        <div class="col-lg-12">
            <div class="ibox ">
                <div class="ibox-content inspinia-timeline">

                    <ul class="layui-timeline" style="background-color: white;">
                        {volist name="processFlowGroups" id="vo"}
                        <li class="layui-timeline-item">
                            <div class="layui-timeline-content layui-text">
                                <h3 class="layui-timeline-title">第{$vo.group}次提交</h3>
                                <p>
                                    {volist name="vo.list" id="processEntity"}
                                <div id="vertical-timeline" class="vertical-container dark-timeline">
                                    <div class="vertical-timeline-block">
                                        <div class="vertical-timeline-icon navy-bg">
                                            <i class="fa fa-briefcase"></i>
                                        </div>
                                        <div class="vertical-timeline-content">
                                            <h4>
                                                审核人：{$processEntity.user.username}
                                                <span>{$processEntity.status_txt}</span>
                                                <span class="vertical-date"><small>{$processEntity.create_time}</small></span>
                                            </h4>
                                        </div>
                                    </div>
                                </div>
                                {/volist}
                                </p>
                            </div>
                        </li>
                        {/volist}
                    </ul>

                </div>
            </div>
        </div>
    </div>
</div>
<div id="reject-form" class="modal fade" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body">
                <div class="row">
                    <div class="col-sm-12">
                        <h3 class="m-t-none m-b"><i class="fa fa-warning" style="color: orange;"></i>拒绝原因</h3>
                        <form role="form" action="{:url('waitReviewAudit',['id'=>$row.id],'json')}" method="post">
                            <input type="hidden" name="status" value="reject">
                            <div class="form-group">
                                <label>拒绝原因：</label>
                                <textarea class="form-control message-input" name="describe"
                                          placeholder="请输入拒绝原因"></textarea>
                            </div>
                            <div>
                                <button class="btn btn-sm btn-primary float-right m-t-n-xs ajax-modal-dialog-reject"
                                        type="button">
                                    <strong>确定</strong>
                                </button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="blueimp-gallery" class="blueimp-gallery">
    <div class="slides"></div>
    <h3 class="title"></h3>
    <a class="prev">‹</a>
    <a class="next">›</a>
    <a class="close">×</a>
    <a class="play-pause"></a>
    <ol class="indicator"></ol>
</div>
{/block}
{block name="css"}
<link href="__ADMIN__/css/plugins/blueimp/css/blueimp-gallery.min.css" rel="stylesheet">
<link rel="stylesheet" href="__ADMIN__/css/process-timeline.css">

<style type="text/css">
    .timeline-item .content {
        border-top: 1px solid #e7eaec !important;
    }

    #vertical-timeline {
        margin: 0 auto;
    }

    .vertical-container {
        width: auto;
        max-width: none;
    }

    .vertical-timeline-block {
        padding-bottom: 10px;
    }

    .lightBoxGallery {
        text-align: left;
    }
</style>
{/block}
{block name="js"}
<script src="__ADMIN__/js/plugins/blueimp/jquery.blueimp-gallery.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {

        $(".ajax-modal-dialog-reject").on("click", function (e) {
            reject()
        })

        function auditPass(e) {
            var index = layer.load(2, {shade: [0.2, '#000']});
            $.ajax({
                url: $(e).attr("href"),
                type: method || "post",
                dataType: 'json',
                data: {
                    status: 'accept',
                },
                success: function (res) {
                    if (res.code === 1) {
                        toast.success(res.msg, {duration: (res.wait || 3) * 1000}).then(() => {
                            layer.close(index);
                            window.location.href = res.url;
                        });
                    } else {
                        toast.warning(res.msg, {duration: (res.wait || 3) * 1000}).then(() => {
                            layer.close(index);
                        });
                        layer.close(index);
                    }
                },
                error: function (error) {
                    layer.close(index);
                    layer.msg(error.responseText);
                },
                complete: function () {
                    setTimeout(function () {
                        layer.close(index);
                    }, 3000)
                }
            });
        }

        function reject() {
            const $form = $("#reject-form").find("form");
            var formData = $form.serialize();
            var action = $form.attr("action");
            if (!action) {
                var url = window.location.href;
            } else {
                //取出第一个字符
                var first = action.slice(0, 1);
                if (first == '/') {
                    var url = action;
                } else {
                    var url = '/' + action
                }
            }
            $.post(url, formData, function (res, status, xhr) {
                if (res.code === 1) {
                    toast.success(res.msg, {duration: (res.wait || 3) * 1000}).then(() => {
                        //layer.close(index);
                        //window.location.href = res.url;
						location.reload(true);
                    });
                } else {
                    toast.error(res.msg, {duration: (res.wait || 3) * 1000}).then(() => {
                        layer.close(index);
                        if (xhr.getResponseHeader('__token__')) {
                            $("[name='__token__']").val(xhr.getResponseHeader('__token__'));
                        }
                    });
                }
            }, 'json');
        }

    });
</script>
{/block}
